package com.jinduplan.planmanager.mvp.presenter

import com.cxz.kotlin.baselibs.ext.ss
import com.cxz.kotlin.baselibs.mvp.BasePresenter
import com.jinduplan.planmanager.mvp.contract.ClockInContract
import com.jinduplan.planmanager.mvp.model.ClockInModel

/**
 * @author chenxz
 * @date 2018/12/1
 * @desc
 */
class ClockInPresenter : BasePresenter<ClockInContract.Model, ClockInContract.View>(), ClockInContract.Presenter {

    override fun createModel(): ClockInContract.Model = ClockInModel()
    override fun uploadClockInPic(file: String, longtitue: Long, latitue: Long, projectid: String) {

        mModel?.uploadClockInPic(file)?.ss(mModel, mView, onSuccess = {
            mView?.uploadPicSuccess(it.data.images)
        }, onError = {

        })
    }


    override fun clockIn(file: String, longtitue: String, latitue: String, projectid: String) {
        mModel?.clockIn(file,longtitue,latitue,projectid)?.ss(mModel, mView, onSuccess = {
            mView?.clockInSuccess()
        }, onError = {

        })

    }

    override fun postProjectLocation(
        project_id: String,
        addr_name: String,
        address: String,
        lat: String,
        lon: String,
        toString: String,
        province: String,
        city: String,
        distict: String,
        mAddr: String
    ) {

        mModel?.postProjectLocation(project_id,addr_name,address,lat,lon,toString,province,city,distict,mAddr)?.ss(mModel, mView, onSuccess = {
            mView?.postProjectLocationSuccess(it.data)
        }, onError = {

        })
    }

    override fun getProjectUploadDetailList(project_id: Int) {

        mModel?.getProjectUploadDetailList(project_id)?.ss(mModel, mView, onSuccess = {
            mView?.setProjectUploadDetailListData(it.data)
        }, onError = {

        })
    }

}